﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.Reports;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service.Reports
{
    public class ReportItemService : IService<ReportItem>
    {
        private readonly GenericRepository<ReportItem> _reportItemRepository;
        private readonly IUnitOfWork _unitOfWork;

        public ReportItemService(IUnitOfWork unitOfWork, GenericRepository<ReportItem> reportItemRepository)
        {
            this._reportItemRepository = reportItemRepository;
            this._unitOfWork = unitOfWork;
        }

        public IQueryable<ReportItem> GetAllElements()
        {
            return _reportItemRepository.GetAll();
        }

        public ReportItem GetElementById(int id)
        {
            return _reportItemRepository.GetById(id);
        }

        public void CreateElement(ReportItem entity)
        {
            _reportItemRepository.Insert(entity);
        }

        public void UpdateElement(ReportItem entity)
        {
            _reportItemRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _reportItemRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
